<?php
	session_start();
		if(!$_SESSION['login'] == 1 && $_SESSION['sessionid'] !== session_id()) {
		header("Location: ./");
		exit;
	}
	
	if($_SESSION['priv'] > 3) {
		$lang = $_SESSION['lang'];
		require_once("include/lang." . $lang . ".php");
		echo ERR_PRIV;
		exit;
	}
		
	include("include/class.mysql.php");
	include("include/layout.php");
			
	html_start();
?>



<head><script language="JavaScript" type="text/javascript">
<!-- Copyright 2005, Sandeep Gangadharan -->
<!-- For more free scripts go to http://sivamdesign.com/scripts/ -->

<!--
function smallwin() {
var numero = document.getElementById("mobile");
SW=window.open('redirect.php?mobile='+numero.value,'NewWin','toolbar=no,menubar=no,location=no,resizable=no,status=no,width=350,height=135,scrollbars=no')
                   // change the name, features and the figures of width and height above to customize the popup window.
SW.moveTo(190,240);  // change the #s at the left to adjust the left and top margins where the popup would open
}
// -->
</script>
</head>


		<br />
		<span class="conin">
			<?php				
				// Edit section
				
					if(empty($_GET['self'])) {
						die("No ID");
					}
					if(!is_numeric($_GET['self'])) {
						die("Invalid ID");
					}
					
					$MySQL->conn();
					$self = $_GET['self'];
					$sql = mysql_query("SELECT * FROM " . DB_PREFIX . "users WHERE id = '$self'") or die(mysql_error());
					while($row = mysql_fetch_array($sql)) {
			$_SESSION['pin']=strip_tags($row['pin']);
			$_SESSION['tel']=strip_tags($row['tel']);
			?>
			
				<legend>Escolha os dados para o seu telefonema</legend>
				
					<br />
					Bem vindo <?=$row['uname'];?>
					<br />
					<br />
					Pin
					<br />	
					<?=$_SESSION['pin'];?>
					
					<br />
					Telefone
					<br />
					<?=$_SESSION['tel'];?>
					<br />					
						
<?}?>






<?php
	
	$id = $_GET['id'];
	$user_group = $_SESSION['group'];
	
	if(isset($id)) {
		if(!is_numeric($id)) {
			print "Id must be numeric!";
			exit;
		}
		
		else {
			$MySQL->conn();
			$sql = mysql_query("SELECT * FROM " . DB_PREFIX . "contacts WHERE id = '$id'") or die(mysql_error());
			
			while($row = mysql_fetch_array($sql)) {
				if($row['user_group'] !== $user_group) {
					print "This contact does not belong to your group!";
					exit;
				}
?>

	<br />
	

	<td style="vertical-align:top;">



						<fieldset style="width:250px;
						<?php
							if(empty($row['ph_home']) && empty($row['ph_work']) && empty($row['ph_mobile'])) {
								echo "display:none;";
								$disp3 = false;
							}
						?>">
							<legend><?=ADDR_PHONE;?></legend>
							<table>
							<?if(!empty($row['ph_home'])) {?>
							<tr><td><b><?=ADDR_HOME;?>:

</b></td></tr>
							<tr><td><?=strip_tags($row['ph_home']);?>

<br />
<?php
$variavelhome=strip_tags($row['ph_home']);
?>


</td></tr>
							<?}?>
							<?if(!empty($row['ph_work'])) {?>
							<tr><td><b><?=ADDR_WORK;?>:</b></td></tr>
							<tr><td><?=strip_tags($row['ph_work']);?>
<?php
$variavelwork=strip_tags($row['ph_work']);
?>

</td></tr>
							<?}?>
							<?if(!empty($row['ph_mobile'])) {?>
							<tr><td><b><?=ADDR_MOBILE;?>:</b></td></tr>
							<tr><td><?=strip_tags($row['ph_mobile']);?>
<?php
$variavelmobile=strip_tags($row['ph_mobile']);
?>




</td></tr>
			<?}?>
							</table>




<?php
$mobile = $_POST["mobile"];
if (!isset($_POST['submit'])) {}
?>
<br />
<form method="post" action="javascript:smallwin()" target=_BLANK >
<br />

<tr>
    <td><strong>Numero:</strong></td>
<br />
    <td> <select name="mobile" id="mobile">
    <option selected>Select</option>
<?if(!empty($row['ph_home'])) {?>
    <option><?=$variavelhome;?></option><?}?>
<?if(!empty($row['ph_work'])) {?>
    <option><?=$variavelwork;?></option><?}?>
<?if(!empty($row['ph_mobile'])) {?>
    <option><?=$variavelmobile;?></option><?}?>
    </select>
    </tr>
    </td>
<br />

<!-- <input type="submit" value="Make Call" name="submit"><br /> -->
<input type="button" value="Make Call" name="submit" onclick="smallwin();"><br />

</form><br />
</fieldset>						
	</span>
<?php
			}
	}
	}
			
			$MySQL->close();
			
	
?>



<?php	html_end();?>